home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / internet / ipport / finger.frm (.txt) next >
Encoding:
Visual Basic Form  |  1995-04-16  |  5.5 KB  |  171 lines

  1. VERSION 2.00
  2. Begin Form frmFinger 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Finger"
  5.    ClientHeight    =   4080
  6.    ClientLeft      =   1200
  7.    ClientTop       =   1500
  8.    ClientWidth     =   5760
  9.    Height          =   4485
  10.    Icon            =   FINGER.FRX:0000
  11.    Left            =   1140
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   4080
  14.    ScaleWidth      =   5760
  15.    Top             =   1155
  16.    Width           =   5880
  17.    Begin CommandButton cmdFinger 
  18.       Caption         =   "&Finger"
  19.       Default         =   -1  'True
  20.       Height          =   375
  21.       Left            =   4440
  22.       TabIndex        =   5
  23.       Top             =   240
  24.       Width           =   1215
  25.    End
  26.    Begin TextBox tResponse 
  27.       FontBold        =   0   'False
  28.       FontItalic      =   0   'False
  29.       FontName        =   "Terminal"
  30.       FontSize        =   9
  31.       FontStrikethru  =   0   'False
  32.       FontUnderline   =   0   'False
  33.       Height          =   3135
  34.       Left            =   120
  35.       MultiLine       =   -1  'True
  36.       ScrollBars      =   3  'Both
  37.       TabIndex        =   3
  38.       Top             =   840
  39.       Width           =   5535
  40.    End
  41.    Begin TextBox tHostAddress 
  42.       Height          =   285
  43.       Left            =   1440
  44.       TabIndex        =   2
  45.       Top             =   480
  46.       Width           =   2895
  47.    End
  48.    Begin TextBox tHostName 
  49.       Height          =   285
  50.       Left            =   1440
  51.       TabIndex        =   1
  52.       Top             =   120
  53.       Width           =   2895
  54.    End
  55.    Begin IPPORT IPPort1 
  56.       EOL             =   ""
  57.       InBufferSize    =   2048
  58.       Left            =   480
  59.       Linger          =   -1  'True
  60.       LocalPort       =   0
  61.       OutBufferSize   =   2048
  62.       Port            =   0
  63.       Top             =   0
  64.    End
  65.    Begin Label Label1 
  66.       BackStyle       =   0  'Transparent
  67.       Caption         =   "Host Address:"
  68.       Height          =   255
  69.       Index           =   1
  70.       Left            =   120
  71.       TabIndex        =   4
  72.       Top             =   480
  73.       Width           =   2175
  74.    End
  75.    Begin Label Label1 
  76.       BackStyle       =   0  'Transparent
  77.       Caption         =   "Host Name:"
  78.       Height          =   255
  79.       Index           =   0
  80.       Left            =   120
  81.       TabIndex        =   0
  82.       Top             =   150
  83.       Width           =   1815
  84.    End
  85. 'Finger Demo -
  86. 'Improvements courtesy of Kenn Nesbitt
  87. '(kenn@nesbitt.demon.co.uk)
  88. Option Explicit
  89. Const DEFAULT = 0
  90. Const HOURGLASS = 11
  91. Sub cmdFinger_Click ()
  92.     Dim HostName As String, UserID As String
  93.     On Error GoTo cmdFingerClickErr:
  94.     ' Set the End-of-Line character
  95.     IPPort1.EOL = Chr$(10)
  96.     ' Display "wait" cursor
  97.     Me.MousePointer = HOURGLASS
  98.     'Close old connection - if any
  99.     IPPort1.Connected = False
  100.     If tHostName.Text <> "" Then
  101.         If InStr(tHostName, "@") = 0 Then
  102.             HostName = tHostName.Text
  103.             UserID = ""
  104.         Else
  105.             HostName = Mid$(tHostName.Text, InStr(tHostName, "@") + 1)
  106.             UserID = Left$(tHostName.Text, InStr(tHostName, "@") - 1)
  107.         End If
  108.         tResponse.Text = HostName
  109.         IPPort1.HostName = HostName
  110.         tHostAddress.Text = IPPort1.HostAddress
  111.     ElseIf tHostAddress.Text <> "" Then
  112.         tResponse.Text = "Resolving " & tHostAddress.Text & "..."
  113.         IPPort1.HostAddress = tHostAddress.Text
  114.         HostName = IPPort1.HostName
  115.         UserID = ""
  116.         tHostName.Text = HostName
  117.     Else
  118.         MsgBox "Please specify a host."
  119.         Exit Sub
  120.     End If
  121.     ' By convention, finger is on port 79
  122.     IPPort1.Port = 79
  123.     ' Ask for connection
  124.     IPPort1.Connected = True
  125.     ' Wait until connection is achieved
  126.     tResponse.Text = "Connecting to " & HostName & "..."
  127.     Do Until IPPort1.Connected: DoEvents: Loop
  128.     ' Send the ID we wish to finger
  129.     IPPort1.DataToSend = UserID & Chr$(10)
  130. cmdFingerClickExit:
  131.     On Error GoTo 0
  132.     Exit Sub
  133. cmdFingerClickErr:
  134.     Me.MousePointer = DEFAULT
  135.     MsgBox "Error " & Err & ": " & Error
  136.     IPPort1.Connected = False
  137.     GoTo cmdFingerClickExit
  138. End Sub
  139. Sub Form_Resize ()
  140.     Dim Margin As Integer
  141.     Margin = tResponse.Left
  142.     tResponse.Height = ScaleHeight - tResponse.Top - Margin
  143.     tResponse.Width = ScaleWidth - 2 * Margin
  144.     cmdFinger.Left = ScaleWidth - cmdFinger.Width - Margin
  145.     tHostName.Width = ScaleWidth - tHostName.Left - cmdFinger.Width - 2 * Margin
  146.     tHostAddress.Width = ScaleWidth - tHostAddress.Left - cmdFinger.Width - 2 * Margin
  147. End Sub
  148. Sub IPPort1_Connected (StatusCode As Integer, Description As String)
  149. tResponse = ""
  150. If Description <> "OK" Then
  151.     MsgBox "Connection error: " & Description
  152.     Me.MousePointer = 0
  153. End If
  154. End Sub
  155. Sub IPPort1_DataIn (Text As String, EOL As Integer)
  156.     If EOL Then Text = Text & Chr$(13) & Chr$(10)
  157.     tResponse.SelStart = Len(tResponse.Text)
  158.     tResponse.SelText = Text
  159. End Sub
  160. Sub IPPort1_Disconnected (StatusCode As Integer, Description As String)
  161. Me.MousePointer = 0
  162. If Description <> "OK" Then
  163.     MsgBox "Connection broken: " & Description
  164. End If
  165. tResponse.SelStart = Len(tResponse.Text)
  166. tResponse.SelText = Chr$(13) & Chr$(10) & " *** Doubleclick on a login ID for more info.***" & Chr$(13) & Chr$(10)
  167. End Sub
  168. Sub tResponse_DblClick ()
  169.     tHostName.Text = tResponse.SelText & "@" & IPPort1.HostName
  170. End Sub
  171.